<template>
    <el-table :data="tranPageInfo.list" style="width: 100%" @selection-change="handSelection">
        <el-table-column type="selection" width="55" />
        <el-table-column type="index" label="序号" width="55" />
        <el-table-column property="tranNo" label="交易流水号">
            <template #default="scope"><a href="javascript:void(0)" v-on:click="view(scope.row.id)">{{ scope.row.tranNo
                    }}</a></template>
            <!-- 插槽：scope.row == user对象 -->
        </el-table-column>
        <el-table-column property="clueDo.fullName" label="客户姓名">
            <template #default="scope"><a href="javascript:void(0)" @click="view(scope.row.id)">{{
                scope.row.clueDo.fullName }}</a></template>
            <!-- 插槽：scope.row == user对象 -->
        </el-table-column>
        <el-table-column property="money" label="交易金额" />
        <el-table-column property="expectedDate" label="预计成交时间" />
        <el-table-column property="stageDo.typeValue" label="交易阶段" />
        <el-table-column property="nextContactTime" label="下次跟踪时间" />
        <el-table-column label="操作" width="145">
            <template #default="scope">
                <el-button type="success" :icon="Check" circle @click="view(scope.row.id)" />
                <el-button type="primary" :icon="Edit" circle @click="edit(scope.row.id)" />
                <el-button type="danger" :icon="Delete" circle @click="del(scope.row.id)" />
            </template>
        </el-table-column>
    </el-table>
    <el-pagination background layout="prev, pager, next, jumper, total" :total="tranPageInfo.total"
        :page-size="tranPageInfo.pageSize" @change="toPage" />
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import {doGet} from '@/http/httpRequest'


const tranPageInfo = ref({
    stageDo: {},
    clueDo: {}
})

let router = useRouter()

onMounted(() => {
    loadTranList(1)
})

//分页查询交易
const loadTranList = async current => {
    //向后端发送请求，查询交易分页信息
    let res = await doGet('/api/tran', {
        current: current
    })
    if (res.data.code == 200) {
        //将查询到的交易分页信息赋值给tranPageInfo
        tranPageInfo.value = res.data.info
    } else {
        showMessage("查询交易分页信息失败",'error')
    }
}

const toPage = (current) => {
    loadTranList(current)
}

//查看交易详情
const view = (id) => {
    router.push({
        path: '/dashboard/tran/' + id
    })
}



</script>

<style scoped></style>